﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="pragma" content="no-cache">  <!-- HTTP 1.1 -->
    <meta http-equiv="cache-control" content="no-cache,must-revalidate">  <!-- HTTP 1.0 -->
    <meta name="renderer" content="webkit|ie-comp|ie-stand" /> <!--优先级：极速模式，兼容模式，IE模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <title>基础权限管理系统</title>
    <link rel="stylesheet" type="text/css" href="./libs/jeasyui-181/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="./libs/jeasyui-181/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="./css/common.css">

    <script type="text/javascript" src="./libs/jeasyui-181/jquery.min.js"></script>
    <script type="text/javascript" src="./libs/jeasyui-181/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="./libs/thUtil.js"></script>
    <script type="text/javascript" src="./libs/pageConfig.js"></script>
    <script type="text/javascript" src="./libs/mock.js"></script>

    <script type="text/javascript">
        importJS('script/index.js?t=' + new Date().getTime());
        //控制导航头的显示隐藏
        $(document).ready(function () {
          if (pageConfig.system && !pageConfig.system.displayHead) {
            $('.header-wrap').hide();
            $('.menu-wrap').css('top',0);
            $('.work-wrap').css('padding-top',0);
          }else{
            $('.header-wrap').show();
            $('.menu-wrap').css('top','40px');
            $('.work-wrap').css('padding-top','40px');
          }
        });
        $(function () {
            var loginInfo = Tools.getItem("loginInfo");

            if (loginInfo == null) {
              if (Tools.cookie.getItem('token')) {
                let token = Tools.cookie.getItem('token');
                Tools.setItem('loginInfo',token);
              }else{
                location.href = 'logout.html';
              }
            }
            //Tools.show('这里是弹出的提示');
            //Tools.alert('这里是警告框弹出的提示');
            //indexAjax.jwtTest();
            indexAjax.userInfo();

            //indexAjax.navigate();

            $('#logout').html('登出系统').click(function () {
                window.location.href = window.router.logout;
            });
            //修改密码
            $('#changePassword').click(function () {
                var dlg = window.$.hDialog({
                    href: window.router.passwordForm + '?n=' + Math.random(),
                    title: '修改密码',
                    width: 570,
                    height: 350,
                    onLoad: function () {
                      window.$('#newPwd2').textbox({validType: "equals['#newPwd']",});
                    },
                    submit: function () {
                        var isValid = window.$('#form').form("validate");
                        if (isValid) {
                            var formData = window.$("#form").serializeJson();
                            console.log(formData);
                            var newPwd = formData.newPwd.trim();
                            var newPwd2 = formData.newPwd2.trim();
                            Network.connect(window.api.userUpdatePwd, 'POST', formData, function (res) {
                                if (res.code == ResponseCode.OK) {
                                    Tools.alert('修改密码成功,请重新登录。', function () {
                                        window.location = window.router.logout;
                                    });

                                }
                            });
                        }
                    }
                });
            });
            $('iframe').attr('src', 'home.html');  //初始化到home页

            //左侧菜单展开折叠
            $('#menuCollapse').click(function () {
                var opts = $('.menu-wrap').sidemenu('options');
                if (!opts.collapsed) {
                    $('.menu-wrap').sidemenu('collapse');
                    $('.menu-wrap').sidemenu('resize', { width: 40 });
                    $('.work-wrap').css('padding-left', '40px').slideDown("slow");
                } else {
                    $('.menu-wrap').sidemenu('expand');
                    $('.menu-wrap').sidemenu('resize', { width: 200 });
                    $('.work-wrap').css('padding-left', '200px').slideDown("slow");
                }
            })
        })
    </script>
</head>
<body>
    <div class="container">
        <!--头部-->
        <div class="header-wrap">
            <div class="header-left clear">
                <img id="menuCollapse" src="image/header/folding-icon.png" alt="collapse" />
                <span>基础权限管理系统</span>
            </div>

            <div class="header-right">
                <span id="username" name="username"> </span>
                <span id="changePassword" name="changePassword"> 修改密码 </span>
                <span id="logout" name="logout" style="cursor:pointer;"></span>
            </div>
        </div>
        <!--左侧菜单-->
        <div class="menu-wrap"></div>
        <!--主体操作区-->
        <div class="work-wrap">
            <iframe src="" frameborder="0" scrolling="no"></iframe>
        </div>
    </div>
</body>

</html>